<!-- #include file="Controller.asp" -->
<!-- #include file="View.asp" -->
<!-- #include file="HtmlHelper.asp" -->
<!-- #include file="include.asp" -->
<%
class MvcApplication
	private appDirectory_, appPath_

    public sub Class_Initialize()
        ' check the web application path
        dim server_path, app_path
        server_path = LCase(Request.ServerVariables("INSTANCE_META_PATH") & "")
        app_path = LCase(Request.ServerVariables("APPL_MD_PATH") + "")
        app_path = Mid(app_path, Len(server_path) + 1)
        if Left(app_path, 5) = "/root" then app_path = Mid(app_path, 6)
        if app_path = "" then app_path = "/"
        AppDirectory = app_path
    end sub

	public property let AppDirectory(value)
		if instr(value, ":") > 0 then
			appDirectory_ = value
		else
			appDirectory_ = Server.MapPath(value)
		end if
		if right(appDirectory_, 1) <> "\" then
			appDirectory_ = appDirectory_ & "\"
		end if
		appDirectory_ = appDirectory_ & "app\"
		appPath_ = value
	end property

    public property get AppDirectory
        AppDirectory = appPath_
    end property

	public default sub Run()
		dim controller, view
		set controller = new class_Controller
		controller.Path = appDirectory_
		controller.Create(Request.QueryString("Controller"))
		controller.DoAction(Request.QueryString("Action"))
		set view = new class_View
		view.Path = appPath & "app/views/"
		view.RenderView controller.ControllerName, controller.ActionName
	end sub

end class

%>